import java.util.Arrays;
import java.util.Scanner;

public class demo5 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] array =new int[]{3,4,1,2,6,0};
        int i = missingNumber(array);
        System.out.println(i);

        System.out.println(Arrays.toString(array));
    }


    public static int missingNumber(int[] nums) {
        Arrays.sort(nums);
        for (int i = 0; i < nums.length; i++) {
            if(nums[i] == i)
                continue;
            else{
                return i;
            }
        }
        return nums.length;
    }
}
